home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Tetris Light 1.0 / source / dialutil.c < prev    next >
Text File  |  1993-07-18  |  3KB  |  82 lines

  1. /******************************************************************************\
  2.  
  3. File:        dialutil.c
  4.  
  5. Purpose:    This module provides routines useful for dialog processing.
  6.             
  7.  
  8. ``Tetris Light'' - a simple implementation of a Tetris game.
  9. Copyright (C) 1993 Hoylen Sue
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program; see the file COPYING.  If not, write to the
  23. Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. \******************************************************************************/
  26.  
  27. #include "local.h"
  28. #include "dialutil.h"
  29.  
  30. /*--------------------------------------------------------------------*/
  31.  
  32. static pascal void box_button(WindowPtr wind, INTEGER itemno)
  33. /* This is the display routine for the userItem which draws a solid
  34.    outline around the default button. */
  35. {
  36.     INTEGER    dummy;
  37.     Rect    rectangle;
  38.     Handle    handle;
  39.     
  40.     GetDItem(wind, itemno, &dummy, &handle, &rectangle);
  41.     PenSize(3, 3);
  42.     FrameRoundRect(&rectangle, 16, 16);
  43. }
  44.  
  45. /*--------------------------------------------------------------------*/
  46.  
  47. void install_hilight_button(DialogPtr dp, INTEGER button_item, INTEGER usr_item)
  48. /* This routine sets the given 'usr_item' to be a userItem whose role is
  49.    to draw the highlighting box around the default button in a dialog
  50.    box.  The rectangle of this user item is set to be around the 'button_item'
  51.    of the given dialog pointed to by 'dp'. */
  52. {
  53.     INTEGER    type;
  54.     Handle    hand;
  55.     Rect    rect;
  56.     
  57.     GetDItem(dp, button_item, &type, &hand, &rect);
  58.     InsetRect(&rect, -4, -4);
  59.     SetDItem(dp, usr_item, userItem + itemDisable, box_button, &rect );
  60. }
  61.  
  62. /*--------------------------------------------------------------------*/
  63.  
  64. void simulate_key_hit(DialogPtr dp, INTEGER button_item)
  65. /* Flashes a push button control from the given dialog. This is a 
  66.    commonly used routine for indicating to the user that the button
  67.    has been hit when they used the keyboard equivalent for it. */
  68. {
  69.     LONGINT final;
  70.     Handle h;
  71.     Rect box;
  72.     INTEGER dummy;
  73.     
  74.     GetDItem(dp, button_item, &dummy, &h, &box);
  75.     
  76.     HiliteControl(h, 1);
  77.     Delay(8, &final);        /* 8 ticks is sufficient */
  78.     HiliteControl(h, 0);
  79. }
  80.  
  81. /*--------------------------------------------------------------------*/
  82.